<template>
  <div id="app">
    <div class="content">
      <music-header @sendMsg="getSongList"></music-header>
      <music-content @sendstatus="pushstatus" :dishstatus="dishstatus" :disconstatus="disconstatus"  :songList="songList" @gomove="playMove"  @updataurl="updataurl" @updatatalking="updatatalking"  @updatapicurl="updatapicurl" :picUrl="picUrl" :talking="talking" :playUrl="playUrl"></music-content>
      <div class="content-foot">
        <audio
          autoplay
          :src="playUrl"
          ref="audio"
          controls
          @pause="changstatus"
          style="width:100%;height:100%"
        ></audio>
      </div>
    </div>
    <div class="mask-box" v-if="hide=hidestatus">
      <div class="mask">
        <div class="video">
          <video :src="movieUrl" controls autoplay></video>
        </div>
        <button @click="closeMv">x</button>
      </div>
    </div>
  </div>
</template>

<script>
import MusicHeader from "@/components/MusicHeader.vue";
import MusicContent from "@/components/MusicContent.vue";

export default {
  name: "App",
  components: {
    "music-header": MusicHeader,
    "music-content": MusicContent,
  },
  data() {
    return {
      playUrl: "",
      songList:[],
      picUrl:"",
      talking:[],
      hidestatus:false,
      movieUrl:"",
      dishstatus:false,
      disconstatus:false
    };
  },
  methods: {
    getSongList:function(data){
      this.songList=data
      // console.log(data[0].id)
      this.$axios.get("/song/detail",{
         params: {
                ids:data[0].id,
                },
      }).then((result) => {
        // console.log(result.data.songs[0].al.picUrl)
        this.picUrl=result.data.songs[0].al.picUrl
      }).catch((err) => {
        console.log(err)
      });
      this.$axios.get("/comment/music",{
         params: {
                id:data[0].id,
                },
      }).then((result) => {
        // console.log(result.data.comments)
        this.talking=result.data.comments
      }).catch((err) => {
        console.log(err)
      });
      this.$axios.get("/song/url",{
         params: {
                id:data[0].id,
                },
      }).then((result) => {
        // console.log(result.data.data[0].url)
        this.playUrl=result.data.data[0].url
        
      }).catch((err) => {
        console.log(err)
      });
    },
    updataurl:function(songUrl){
      // console.log(songUrl)
      this.playUrl=songUrl
    },
    updatatalking:function(talking){
      this.talking=talking
    },
    updatapicurl:function(picUrl){
      this.picUrl=picUrl
    },
    playMove:function(url,status){
      console.log(url,status)
      this.hidestatus=status,
      this.movieUrl=url,
      this.$refs.audio.pause()
      
    },
    closeMv:function(){
      this.hidestatus=false
    },
    changstatus:function(){
      this.dishstatus=false,
      this.disconstatus=false
    },
    pushstatus:function(status1,status2){
      this.dishstatus=status1,
      this.disconstatus=status2
    }
    
  },
};
</script>

<style>
/* 样式重置 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

li {
  list-style: none;
}

a {
  text-decoration: none;
  color: #fff;
}
/* 总体样式部分 */
#app {
  position: relative;
  background: url(./assets/bg.jpg) no-repeat;
  width: 100vw;
  height: 100vh;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  --themeColor: #1baad5;
}
.content {
  position: absolute;
  width: 800px;
  height: 600px;
  border-radius: 10px;
}
.content-top {
  box-sizing: border-box;
  height: 60px;
  padding: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--themeColor);
}
.content-mid {
  height: 480px;
  width: 100%;
  display: flex;
  border-bottom: 1px dotted var(--themeColor);
  background-color: rgba(255, 255, 255, 0.5);
}
.content-mid .mid-left {
  flex: 1;
  height: 100%;
  /* background: palevioletred; */
  overflow-y: auto;
}
.content-mid .mid-mid {
  flex: 2;
  height: 100%;
  /* background: pink; */
}
.content-mid .mid-right {
  flex: 1;
  height: 100%;
  /* background: powderblue; */
}
.content-foot {
  height: 60px;
  width: 100%;
  background-color: #f1f3f4;
}
/* 歌曲清单部分 */
.songbox {
  font-size: 12px;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: space-between;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  padding: 0 5px;
  height: 40px;
  color: #fff;
}
.icon {
  width: 25px;
  height: 25px;
  display: block;
  background: url(./assets/table.png) no-repeat;
}
.mp3 {
  background-position: -18px -21px;
}
.songbox:nth-child(2n) {
  background-color: rgba(255, 255, 255, 0.5);
}
.mv {
  background-position: 0 -45px;
}
/* 评论区 */
.talking {
  box-sizing: border-box;
  padding: 5px;
  width: 100%;
  min-height: 25px;
  margin-bottom: 10px;
  /* border: 1px solid springgreen; */
}
.talk-top {
  display: flex;
}
.talk-top img {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  /* border: 1px solid red; */
  overflow: hidden;
  margin-right: 10px;
}
.talk-und {
  margin-left: 35px;
  height: 100%;
  font-size: 14px;
  /* background: #ffffff; */
}
/* 遮罩 */
.mask-box{
  position: absolute;
  z-index: 10;
  height: 100vh;
  width: 100vw;
  background: #474747;
}
.mask-box .mask button{
  position: absolute;
  right: 0;
  top: 0;
  border: 0;
  background: none;
}
.video{
  position: absolute;
  width: 40vw;
  height: 100vh;
  /* background: #ffffff; */
  left: 0;
  right: 0;
  margin: 0 auto;
  text-align: center;
}
video{
  width: 650px;
  height: 400px;
  margin-top: 250px;
  
}
.hide{
  display: none;
}
</style>
